package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.*;

@RestController("userShopController")
@RequestMapping("/user/shop")
@Slf4j
@Api(tags = "店铺接口")
public class ShopController {
    public static final String KEY="SHOP_STATUS";

    @Autowired
    private RedisTemplate redisTemplate;

//    @PutMapping("/{status}")
//    @ApiOperation("设置店铺状态")
//    public Result setShopStatus(@PathVariable Integer status) {
//        ValueOperations valueOperations = redisTemplate.opsForValue();
//        valueOperations.set("SHOP_STATUS", status);
//        return Result.success();
//    }

    @GetMapping("/status")
    @ApiOperation("获取状态")
    public Result<Integer> getShopStatus() {
        log.info("店铺状态获取中");
        ValueOperations valueOperations = redisTemplate.opsForValue();
        Integer status = (Integer) valueOperations.get(KEY);
        return Result.success(status);
    }

}
